﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CSharpAlgorithm.Base;

namespace CSharpAlgorithm
{
    class SpecialPath
    {
        public SpecialPath()
        {
            string[] input = TestConsole.ReadLine().Split();
            int v = Int32.Parse(input[0]);
            int e = Int32.Parse(input[1]);
            List<Edge>[] G = new List<Edge>[v + 1];
            for (int i = 1; i <= v; i++)
            {
                G[i] = new List<Edge>();
            }
            int s = 0, t = 0;
            for (int i = 0; i < e; i++)
            {
                input = TestConsole.ReadLine().Split();
                int from = Int32.Parse(input[0]);
                int to = Int32.Parse(input[1]);
                int cost = Int32.Parse(input[2]);
                if (i == 0)
                {
                    s = from;
                    t = to;
                }
                Edge edge = new Edge(from, to, cost, 0, 0);
                G[from].Add(edge);
            }
            input = TestConsole.ReadLine().Split();
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            Dijkstra dijkstra = new Dijkstra(G, v);
            int sabt = dijkstra.ShortestPath(s)[a] + dijkstra.ShortestPath(a)[b] + dijkstra.ShortestPath(b)[t];
            int sbat = dijkstra.ShortestPath(s)[b] + dijkstra.ShortestPath(b)[a] + dijkstra.ShortestPath(a)[t];
            Console.Write(sabt + " " + sbat);
        }
    }
}
